using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.IO;

namespace LdExpress
{
    public class Document
    {
        public string FileFullPath = "";
        public static string FileDirPhysicalPathContentItem
        {
            get
            {
                return System.Web.HttpContext.Current.Server.MapPath("/") + "Import\\";
            }
        }
        public static string FileDirPhysicalPath
        {
            get
            {
                return System.Web.HttpContext.Current.Server.MapPath("./");// +"DOCUMENTS\\";
            }
        }
        public static string GetRelativeFilePath(string strFileFullPath)
        {
            string retVal = "";
            int nLen = System.Web.HttpContext.Current.Server.MapPath("/").Length;
            if (strFileFullPath.Length > nLen) retVal = strFileFullPath.Substring(nLen);
            return retVal;
        }
        public string Get_FileFullPath
        {
            get
            {
                return FileFullPath;
            }
        }
        public static void CheckDirectory(string DirectoryPath)
        {
            //if Directory don't exist, we will create new Directory
            if (!System.IO.Directory.Exists(DirectoryPath))
            {
                System.IO.Directory.CreateDirectory(DirectoryPath);
                if (!System.IO.Directory.Exists(DirectoryPath + "\\" + HistoryDirName))
                {
                    System.IO.Directory.CreateDirectory(DirectoryPath + "\\" + HistoryDirName);
                }
            }
        }
        public static string GetShortFileName(string strFullUploadedFileName)
        {
            int nLast = strFullUploadedFileName.LastIndexOf('\\');
            if (nLast < 0) nLast = strFullUploadedFileName.LastIndexOf('/');
            string strFileName = "" + strFullUploadedFileName;
            if ((nLast >= 0) && (nLast < strFullUploadedFileName.Length - 1))
                strFileName = strFullUploadedFileName.Substring(nLast + 1);
            return strFileName;
        }
        public const string HistoryDirName = "HistoryFiles";     
    }
}